/**
 * 
 */
package com.taobao.wolfwolf.hibernate.dao.impl;

import java.util.List;


import com.taobao.wolfwolf.hibernate.dao.DepotDao;
import com.taobao.wolfwolf.hibernate.pojo.Depot;
import com.taobao.wolfwolf.hibernate.pojo.Sitem;

/**
 * @author Tux
 *
 * 创建时间: 2011-5-21 下午08:33:16
 */
@SuppressWarnings("unchecked")
public class DepotDaoImpl extends BaseDaoImpl implements DepotDao {

	public Depot findById(int id) throws Exception {
		return (Depot) getHibernateTemplate().get(Depot.class, id);
	}
	
	public List<Depot> findByName(String name) throws Exception {
		return super.findByProperty(Depot.class, "name", name);
	}

	public List<Depot> findAll() throws Exception {
		return getHibernateTemplate().find("from Depot");
	}

	public long getTotal() throws Exception {
		return super.countByCriteria(Depot.class);
	}

	public List<Depot> paging(int page, int limit) throws Exception {
		return super.findByCriteriaByPage(Depot.class, page, limit);
	}
	
	public Depot findBySitem(Sitem sitem) throws Exception {
		Depot depot =  (Depot) super.findByProperty(Depot.class, "sitem", sitem).get(0);
		return depot;
	}
}
